public class Test5 {
    public static MySingleList.ListNone mergeTwoLists(MySingleList.ListNone headA,
                                               MySingleList.ListNone headB) {

        //定义一个傀儡节点（虚拟节点）：头节点  此时涉及到了 获取静态内部类对象
        MySingleList.ListNone newH = new MySingleList.ListNone(-1);

        MySingleList.ListNone tmp = newH;

        while(headA != null && headB != null) {
            if(headA.val < headB.val) {
                tmp.next = headA;
                headA = headA.next;
                //tmp = tmp.next;
            } else {
                tmp.next = headB;
                headB = headB.next;
                //tmp = tmp.next;
            }
            tmp = tmp.next;
        }
        if(headA != null) {
            tmp.next = headA;
        }
        if(headB != null) {
            tmp.next = headB;
        }
        return newH.next;
    }

    public static void main(String[] args) {
        MySingleList mySingleList1 = new MySingleList();

        mySingleList1.addFirst(12);
        mySingleList1.addFirst(23);
        mySingleList1.addFirst(34);
        mySingleList1.addFirst(45);
        mySingleList1.display();
        System.out.println("================");
        MySingleList mySingleList2 = new MySingleList();
        mySingleList2.addFirst(2);
        mySingleList2.addFirst(3);
        mySingleList2.addFirst(4);
        mySingleList2.addFirst(95);
        mySingleList2.display();
        System.out.println("=========合并===========0");

            MySingleList.ListNone ret = mergeTwoLists(mySingleList1.head,mySingleList2.head);
            mySingleList2.display(ret);
    }
}
